<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - mbi.info - test/impl/results_reporter.ipp</title>
  <link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../index.html">directory</a> - <a href="index.html">test/impl</a> - results_reporter.ipp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>mbi.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-01-23</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">55</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">58.2 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">32</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : //  (C) Copyright Gennadiy Rozental 2005-2008.
<span class="lineNum">       2 </span>                : //  Distributed under the Boost Software License, Version 1.0.
<span class="lineNum">       3 </span>                : //  (See accompanying file LICENSE_1_0.txt or copy at
<span class="lineNum">       4 </span>                : //  http://www.boost.org/LICENSE_1_0.txt)
<span class="lineNum">       5 </span>                : 
<span class="lineNum">       6 </span>                : //  See http://www.boost.org/libs/test for the library home page.
<span class="lineNum">       7 </span>                : //
<span class="lineNum">       8 </span>                : //  File        : $RCSfile$
<span class="lineNum">       9 </span>                : //
<span class="lineNum">      10 </span>                : //  Version     : $Revision: 49312 $
<span class="lineNum">      11 </span>                : //
<span class="lineNum">      12 </span>                : //  Description : result reporting facilties
<span class="lineNum">      13 </span>                : // ***************************************************************************
<span class="lineNum">      14 </span>                : 
<span class="lineNum">      15 </span>                : #ifndef BOOST_TEST_RESULTS_REPORTER_IPP_020105GER
<span class="lineNum">      16 </span>                : #define BOOST_TEST_RESULTS_REPORTER_IPP_020105GER
<span class="lineNum">      17 </span>                : 
<span class="lineNum">      18 </span>                : // Boost.Test
<span class="lineNum">      19 </span>                : #include &lt;boost/test/results_reporter.hpp&gt;
<span class="lineNum">      20 </span>                : #include &lt;boost/test/unit_test_suite_impl.hpp&gt;
<span class="lineNum">      21 </span>                : #include &lt;boost/test/results_collector.hpp&gt;
<span class="lineNum">      22 </span>                : #include &lt;boost/test/framework.hpp&gt;
<span class="lineNum">      23 </span>                : #include &lt;boost/test/output/plain_report_formatter.hpp&gt;
<span class="lineNum">      24 </span>                : #include &lt;boost/test/output/xml_report_formatter.hpp&gt;
<span class="lineNum">      25 </span>                : 
<span class="lineNum">      26 </span>                : // Boost
<span class="lineNum">      27 </span>                : #include &lt;boost/scoped_ptr.hpp&gt;
<span class="lineNum">      28 </span>                : #include &lt;boost/io/ios_state.hpp&gt;
<span class="lineNum">      29 </span>                : typedef ::boost::io::ios_base_all_saver io_saver_type;
<span class="lineNum">      30 </span>                : 
<span class="lineNum">      31 </span>                : // STL
<span class="lineNum">      32 </span>                : #include &lt;iostream&gt;
<span class="lineNum">      33 </span>                : 
<span class="lineNum">      34 </span>                : #include &lt;boost/test/detail/suppress_warnings.hpp&gt;
<span class="lineNum">      35 </span>                : 
<span class="lineNum">      36 </span>                : //____________________________________________________________________________//
<span class="lineNum">      37 </span>                : 
<span class="lineNum">      38 </span>                : namespace boost {
<span class="lineNum">      39 </span>                : 
<span class="lineNum">      40 </span>                : namespace unit_test {
<span class="lineNum">      41 </span>                : 
<span class="lineNum">      42 </span>                : namespace results_reporter {
<span class="lineNum">      43 </span>                : 
<span class="lineNum">      44 </span>                : // ************************************************************************** //
<span class="lineNum">      45 </span>                : // **************        result reporter implementation        ************** //
<span class="lineNum">      46 </span>                : // ************************************************************************** //
<span class="lineNum">      47 </span>                : 
<span class="lineNum">      48 </span>                : namespace {
<span class="lineNum">      49 </span>                : 
<span class="lineNum">      50 </span><span class="lineCov">              2 : struct results_reporter_impl : test_tree_visitor {</span>
<span class="lineNum">      51 </span>                :     // Constructor
<span class="lineNum">      52 </span><span class="lineCov">              2 :     results_reporter_impl()</span>
<span class="lineNum">      53 </span>                :     : m_output( &amp;std::cerr )
<span class="lineNum">      54 </span>                :     , m_stream_state_saver( new io_saver_type( std::cerr ) )
<span class="lineNum">      55 </span>                :     , m_report_level( CONFIRMATION_REPORT )
<span class="lineNum">      56 </span><span class="lineCov">              2 :     , m_formatter( new output::plain_report_formatter )</span>
<span class="lineNum">      57 </span><span class="lineCov">              2 :     {}</span>
<span class="lineNum">      58 </span>                : 
<span class="lineNum">      59 </span>                :     // test tree visitor interface implementation
<span class="lineNum">      60 </span><span class="lineNoCov">              0 :     void    visit( test_case const&amp; tc )</span>
<span class="lineNum">      61 </span>                :     {
<span class="lineNum">      62 </span><span class="lineNoCov">              0 :         m_formatter-&gt;test_unit_report_start( tc, *m_output );</span>
<span class="lineNum">      63 </span><span class="lineNoCov">              0 :         m_formatter-&gt;test_unit_report_finish( tc, *m_output );</span>
<span class="lineNum">      64 </span><span class="lineNoCov">              0 :     }</span>
<span class="lineNum">      65 </span><span class="lineNoCov">              0 :     bool    test_suite_start( test_suite const&amp; ts )</span>
<span class="lineNum">      66 </span>                :     {
<span class="lineNum">      67 </span><span class="lineNoCov">              0 :         m_formatter-&gt;test_unit_report_start( ts, *m_output );</span>
<span class="lineNum">      68 </span>                : 
<span class="lineNum">      69 </span><span class="lineNoCov">              0 :         if( m_report_level == DETAILED_REPORT &amp;&amp; !results_collector.results( ts.p_id ).p_skipped )</span>
<span class="lineNum">      70 </span><span class="lineNoCov">              0 :             return true;</span>
<span class="lineNum">      71 </span>                : 
<span class="lineNum">      72 </span><span class="lineNoCov">              0 :         m_formatter-&gt;test_unit_report_finish( ts, *m_output );</span>
<span class="lineNum">      73 </span><span class="lineNoCov">              0 :         return false;</span>
<span class="lineNum">      74 </span>                :     }
<span class="lineNum">      75 </span><span class="lineNoCov">              0 :     void    test_suite_finish( test_suite const&amp; ts )</span>
<span class="lineNum">      76 </span>                :     {
<span class="lineNum">      77 </span><span class="lineNoCov">              0 :         m_formatter-&gt;test_unit_report_finish( ts, *m_output );</span>
<span class="lineNum">      78 </span><span class="lineNoCov">              0 :     }</span>
<span class="lineNum">      79 </span>                : 
<span class="lineNum">      80 </span>                :     typedef scoped_ptr&lt;io_saver_type&gt; saver_ptr;
<span class="lineNum">      81 </span>                : 
<span class="lineNum">      82 </span>                :     // Data members
<span class="lineNum">      83 </span>                :     std::ostream*       m_output;
<span class="lineNum">      84 </span>                :     saver_ptr           m_stream_state_saver;
<span class="lineNum">      85 </span>                :     report_level        m_report_level;
<span class="lineNum">      86 </span>                :     scoped_ptr&lt;format&gt;  m_formatter;
<span class="lineNum">      87 </span>                : };
<span class="lineNum">      88 </span>                : 
<span class="lineNum">      89 </span><span class="lineCov">             24 : results_reporter_impl&amp; s_rr_impl() { static results_reporter_impl the_inst; return the_inst; }</span>
<span class="lineNum">      90 </span>                : 
<span class="lineNum">      91 </span>                : } // local namespace
<span class="lineNum">      92 </span>                : 
<span class="lineNum">      93 </span>                : // ************************************************************************** //
<span class="lineNum">      94 </span>                : // **************              report configuration            ************** //
<span class="lineNum">      95 </span>                : // ************************************************************************** //
<span class="lineNum">      96 </span>                : 
<span class="lineNum">      97 </span>                : void
<span class="lineNum">      98 </span><span class="lineCov">              2 : set_level( report_level l )</span>
<span class="lineNum">      99 </span>                : {
<span class="lineNum">     100 </span><span class="lineCov">              2 :     if( l != INV_REPORT_LEVEL )</span>
<span class="lineNum">     101 </span><span class="lineNoCov">              0 :         s_rr_impl().m_report_level = l;</span>
<span class="lineNum">     102 </span><span class="lineCov">              2 : }</span>
<span class="lineNum">     103 </span>                : 
<span class="lineNum">     104 </span>                : //____________________________________________________________________________//
<span class="lineNum">     105 </span>                : 
<span class="lineNum">     106 </span>                : void
<span class="lineNum">     107 </span><span class="lineNoCov">              0 : set_stream( std::ostream&amp; ostr )</span>
<span class="lineNum">     108 </span>                : {
<span class="lineNum">     109 </span><span class="lineNoCov">              0 :     s_rr_impl().m_output = &amp;ostr;</span>
<span class="lineNum">     110 </span><span class="lineNoCov">              0 :     s_rr_impl().m_stream_state_saver.reset( new io_saver_type( ostr ) );</span>
<span class="lineNum">     111 </span><span class="lineNoCov">              0 : }</span>
<span class="lineNum">     112 </span>                : 
<span class="lineNum">     113 </span>                : //____________________________________________________________________________//
<span class="lineNum">     114 </span>                : 
<span class="lineNum">     115 </span>                : std::ostream&amp;
<span class="lineNum">     116 </span><span class="lineNoCov">              0 : get_stream()</span>
<span class="lineNum">     117 </span>                : {
<span class="lineNum">     118 </span><span class="lineNoCov">              0 :     return *s_rr_impl().m_output;</span>
<span class="lineNum">     119 </span>                : }
<span class="lineNum">     120 </span>                : 
<span class="lineNum">     121 </span>                : //____________________________________________________________________________//
<span class="lineNum">     122 </span>                : 
<span class="lineNum">     123 </span>                : void
<span class="lineNum">     124 </span><span class="lineCov">              2 : set_format( output_format rf )</span>
<span class="lineNum">     125 </span>                : {
<span class="lineNum">     126 </span><span class="lineCov">              2 :     switch( rf ) {</span>
<span class="lineNum">     127 </span>                :     case CLF:
<span class="lineNum">     128 </span><span class="lineCov">              2 :         set_format( new output::plain_report_formatter );</span>
<span class="lineNum">     129 </span><span class="lineCov">              2 :         break;</span>
<span class="lineNum">     130 </span>                :     case XML:
<span class="lineNum">     131 </span><span class="lineNoCov">              0 :         set_format( new output::xml_report_formatter );</span>
<span class="lineNum">     132 </span>                :         break;
<span class="lineNum">     133 </span>                :     }
<span class="lineNum">     134 </span><span class="lineCov">              2 : }</span>
<span class="lineNum">     135 </span>                : 
<span class="lineNum">     136 </span>                : //____________________________________________________________________________//
<span class="lineNum">     137 </span>                : 
<span class="lineNum">     138 </span>                : void
<span class="lineNum">     139 </span><span class="lineCov">              2 : set_format( results_reporter::format* f )</span>
<span class="lineNum">     140 </span>                : {
<span class="lineNum">     141 </span><span class="lineCov">              2 :     if( f )</span>
<span class="lineNum">     142 </span><span class="lineCov">              2 :         s_rr_impl().m_formatter.reset( f );</span>
<span class="lineNum">     143 </span><span class="lineCov">              2 : }</span>
<span class="lineNum">     144 </span>                : 
<span class="lineNum">     145 </span>                : //____________________________________________________________________________//
<span class="lineNum">     146 </span>                : 
<span class="lineNum">     147 </span>                : // ************************************************************************** //
<span class="lineNum">     148 </span>                : // **************               report initiation              ************** //
<span class="lineNum">     149 </span>                : // ************************************************************************** //
<span class="lineNum">     150 </span>                : 
<span class="lineNum">     151 </span>                : void
<span class="lineNum">     152 </span><span class="lineCov">              2 : make_report( report_level l, test_unit_id id )</span>
<span class="lineNum">     153 </span>                : {
<span class="lineNum">     154 </span><span class="lineCov">              2 :     if( l == INV_REPORT_LEVEL )</span>
<span class="lineNum">     155 </span><span class="lineCov">              2 :         l = s_rr_impl().m_report_level;</span>
<span class="lineNum">     156 </span>                : 
<span class="lineNum">     157 </span><span class="lineCov">              2 :     if( l == NO_REPORT )</span>
<span class="lineNum">     158 </span><span class="lineNoCov">              0 :         return;</span>
<span class="lineNum">     159 </span>                : 
<span class="lineNum">     160 </span><span class="lineCov">              2 :     if( id == INV_TEST_UNIT_ID )</span>
<span class="lineNum">     161 </span><span class="lineCov">              2 :         id = framework::master_test_suite().p_id;</span>
<span class="lineNum">     162 </span>                : 
<span class="lineNum">     163 </span><span class="lineCov">              2 :     s_rr_impl().m_stream_state_saver-&gt;restore();</span>
<span class="lineNum">     164 </span>                : 
<span class="lineNum">     165 </span><span class="lineCov">              2 :     report_level bkup = s_rr_impl().m_report_level;</span>
<span class="lineNum">     166 </span><span class="lineCov">              2 :     s_rr_impl().m_report_level = l;</span>
<span class="lineNum">     167 </span>                : 
<span class="lineNum">     168 </span><span class="lineCov">              2 :     s_rr_impl().m_formatter-&gt;results_report_start( *s_rr_impl().m_output );</span>
<span class="lineNum">     169 </span>                : 
<span class="lineNum">     170 </span><span class="lineCov">              2 :     switch( l ) {</span>
<span class="lineNum">     171 </span>                :     case CONFIRMATION_REPORT:
<span class="lineNum">     172 </span><span class="lineCov">              2 :         s_rr_impl().m_formatter-&gt;do_confirmation_report( framework::get&lt;test_unit&gt;( id ), *s_rr_impl().m_output );</span>
<span class="lineNum">     173 </span><span class="lineCov">              2 :         break;</span>
<span class="lineNum">     174 </span>                :     case SHORT_REPORT:
<span class="lineNum">     175 </span>                :     case DETAILED_REPORT:
<span class="lineNum">     176 </span><span class="lineNoCov">              0 :         traverse_test_tree( id, s_rr_impl() );</span>
<span class="lineNum">     177 </span>                :         break;
<span class="lineNum">     178 </span>                :     default:
<span class="lineNum">     179 </span>                :         break;
<span class="lineNum">     180 </span>                :     }
<span class="lineNum">     181 </span>                : 
<span class="lineNum">     182 </span><span class="lineCov">              2 :     s_rr_impl().m_formatter-&gt;results_report_finish( *s_rr_impl().m_output );</span>
<span class="lineNum">     183 </span><span class="lineCov">              2 :     s_rr_impl().m_report_level = bkup;</span>
<span class="lineNum">     184 </span>                : }
<span class="lineNum">     185 </span>                : 
<span class="lineNum">     186 </span>                : //____________________________________________________________________________//
<span class="lineNum">     187 </span>                : 
<span class="lineNum">     188 </span>                : } // namespace results_reporter
<span class="lineNum">     189 </span>                : 
<span class="lineNum">     190 </span>                : } // namespace unit_test
<span class="lineNum">     191 </span>                : 
<span class="lineNum">     192 </span>                : } // namespace boost
<span class="lineNum">     193 </span>                : 
<span class="lineNum">     194 </span>                : //____________________________________________________________________________//
<span class="lineNum">     195 </span>                : 
<span class="lineNum">     196 </span>                : #include &lt;boost/test/detail/enable_warnings.hpp&gt;
<span class="lineNum">     197 </span>                : 
<span class="lineNum">     198 </span>                : #endif // BOOST_TEST_RESULTS_REPORTER_IPP_020105GER
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
